package com.wanmait.schedule.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.schedule.entity.LoginLog;
import com.wanmait.schedule.mapper.LoginLogMapper;
import com.wanmait.schedule.service.LoginLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 登录日志表 服务实现类
 * </p>
 *
 * @author wanmait
 * @since 2022-12-05
 */
@Service
public class LoginLogServiceImpl extends ServiceImpl<LoginLogMapper, LoginLog> implements LoginLogService {
    @Resource
    private LoginLogMapper loginLogMapper;

    @Override
    public PageInfo<LoginLog> list(LoginLog loginLog, Integer pageNum) {
        if (pageNum == null) {
            pageNum = 1;
        }
        PageHelper.startPage(pageNum, 6);
       /* LambdaQueryWrapper<LoginLog> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(loginLog.getTeacherId() != null, LoginLog::getTeacherId, loginLog.getTeacherId());
        queryWrapper.eq(loginLog.getStudentId() != null, LoginLog::getStudentId, loginLog.getStudentId());
        queryWrapper.like(StringUtils.isNotBlank(loginLog.getIp()), LoginLog::getIp, loginLog.getIp());
        queryWrapper.eq(loginLog.getLoginTime() != null, LoginLog::getLoginTime, loginLog.getLoginTime());*/
//        List<LoginLog>  loginLogs = loginLogMapper.selectList(queryWrapper);
        List<LoginLog> loginLogs = loginLogMapper.list();
        PageInfo<LoginLog> pageInfo = new PageInfo<>(loginLogs,10);
        return  pageInfo;
    }

}
